var express = require('express');
var UploadRouter = require('./routers/UploadRouter');
var LogAPIRouter = require('./routers/LogAPIRouter');
var MongoDB = require('./dao/MongoDB');

var logger = new require("./log/Logger")("App");
var port = 3000;
var app = express();

app.use('/', express.static(__dirname + '/static'));

app.use('/logApi', LogAPIRouter);
app.post('/upload', UploadRouter);

process.on('uncaughtException', function(err) {
    logger.error('Caught exception: ', err);
});

MongoDB.initDBConnection().then(function() {
    app.listen(port); //指定端口并启动express web服务
    logger.info("server is running port:" + port);
})
